<?php
/**
 * @author Feng
 * @date 2012-6-15
 */
class picture_photo_keyword_concept extends system_concept_abstract {
	
	public function init() {
		$this->setModel('picture_photo_keyword_model', 'photo_keyword');
		$this->setModelCols('photo_keyword', array('keyword_id', 'photo_id'));
	}
	
	public function save($row) {
		$row->set('photo_id', intval($row->get('photo_id')));
		$row->set('keyword_id', intval($row->get('keyword_id')));
		
		if($row->getPhotoId() && $row->getKeywordId() && !$this->fetch(array('photo_id = ?' => $row->getPhotoId(), 'keyword_id = ?' => $row->getKeywordId()))) {
			$this->getModel('photo_keyword')->insert($row->getModelData('photo_keyword'));
		}
		return $row;
	}

}
